<!DOCTYPE html>
<html lang="zh-cn">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="robots" content="noodp" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
        <title>MySQL - 我的Hugo博客</title><meta name="Description" content=""><meta property="og:title" content="MySQL" />
<meta property="og:description" content="参考博客作者AmourLee
https://www.cnblogs.com/dongl961230/p/13260873.html
1.MySQL下载 https://dev.mysql.com/downloads/mysql/
2.解压 下载完成后解压到自己的想要安装的目录下，然后需要手动创建一个 my.ini 文件：这个文件用来配置安装MySQL时的配置：例如端口号、最大连接数、字符集 、数据的存放位置、存储引擎
3配置my.ini文件 将下面的配置复制到自己创建的my.ini文件中，但是要注意修改自己的安装路径：basedir和datadir 有注释按照注释修改
[mysqld] # 设置3306端口 port=3306 # 自定义设置mysql的安装目录，即解压mysql压缩包的目录 basedir=E:\\tools\mysql8.0\mysql-8.0.20-winx64 # 自定义设置mysql数据库的数据存放目录 datadir=E:\\tools\mysql8.0\mysql-8.0.20-winx64\mysqlData # 允许最大连接数 max_connections=200 # 允许连接失败的次数，这是为了防止有人从该主机试图攻击数据库系统 max_connect_errors=10 # 服务端使用的字符集默认为UTF8 character-set-server=utf8mb4 # 创建新表时将使用的默认存储引擎 default-storage-engine=INNODB # 默认使用“mysql_native_password”插件认证 default_authentication_plugin=mysql_native_password [mysql] # 设置mysql客户端默认字符集 default-character-set=utf8mb4 [client] # 设置mysql客户端连接服务端时默认使用的端口和默认字符集 port=3306 default-character-set=utf8mb4 4.初始化  mysqld &ndash;initialize &ndash;console mysqld &ndash;install net start mysql  5.修改密码 win&#43;R开启新的界面进入MySQL的bin目录然后依次执行命令，来修改客户端连接密码；
 mysql -u root -p alter user root@localhost identified by &lsquo;root&rsquo;;  回车界面出现：Query OK 证明修改成功。" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://xls7771.gitee.io/posts/mysql/" />
<meta property="article:published_time" content="2020-07-23T17:07:33+08:00" />
<meta property="article:modified_time" content="2020-07-23T17:07:33+08:00" />
<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="MySQL"/>
<meta name="twitter:description" content="参考博客作者AmourLee
https://www.cnblogs.com/dongl961230/p/13260873.html
1.MySQL下载 https://dev.mysql.com/downloads/mysql/
2.解压 下载完成后解压到自己的想要安装的目录下，然后需要手动创建一个 my.ini 文件：这个文件用来配置安装MySQL时的配置：例如端口号、最大连接数、字符集 、数据的存放位置、存储引擎
3配置my.ini文件 将下面的配置复制到自己创建的my.ini文件中，但是要注意修改自己的安装路径：basedir和datadir 有注释按照注释修改
[mysqld] # 设置3306端口 port=3306 # 自定义设置mysql的安装目录，即解压mysql压缩包的目录 basedir=E:\\tools\mysql8.0\mysql-8.0.20-winx64 # 自定义设置mysql数据库的数据存放目录 datadir=E:\\tools\mysql8.0\mysql-8.0.20-winx64\mysqlData # 允许最大连接数 max_connections=200 # 允许连接失败的次数，这是为了防止有人从该主机试图攻击数据库系统 max_connect_errors=10 # 服务端使用的字符集默认为UTF8 character-set-server=utf8mb4 # 创建新表时将使用的默认存储引擎 default-storage-engine=INNODB # 默认使用“mysql_native_password”插件认证 default_authentication_plugin=mysql_native_password [mysql] # 设置mysql客户端默认字符集 default-character-set=utf8mb4 [client] # 设置mysql客户端连接服务端时默认使用的端口和默认字符集 port=3306 default-character-set=utf8mb4 4.初始化  mysqld &ndash;initialize &ndash;console mysqld &ndash;install net start mysql  5.修改密码 win&#43;R开启新的界面进入MySQL的bin目录然后依次执行命令，来修改客户端连接密码；
 mysql -u root -p alter user root@localhost identified by &lsquo;root&rsquo;;  回车界面出现：Query OK 证明修改成功。"/>
<meta name="application-name" content="我的Hugo博客">
<meta name="apple-mobile-web-app-title" content="我的Hugo博客"><link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
        <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
        <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="manifest" href="/site.webmanifest"><link rel="canonical" href="https://xls7771.gitee.io/posts/mysql/" /><link rel="prev" href="https://xls7771.gitee.io/posts/tomcat/" /><link rel="next" href="https://xls7771.gitee.io/posts/mybatisplus/" /><link rel="stylesheet" href="/lib/normalize/normalize.min.css"><link rel="stylesheet" href="/css/style.min.css"><link rel="stylesheet" href="/lib/fontawesome-free/all.min.css"><link rel="stylesheet" href="/lib/animate/animate.min.css"><script type="application/ld+json">
    {
        "@context": "http://schema.org",
        "@type": "BlogPosting",
        "headline": "MySQL",
        "inLanguage": "zh-cn",
        "mainEntityOfPage": {
            "@type": "WebPage",
            "@id": "https:\/\/xls7771.gitee.io\/posts\/mysql\/"
        },"genre": "posts","wordcount":  70 ,
        "url": "https:\/\/xls7771.gitee.io\/posts\/mysql\/","datePublished": "2020-07-23T17:07:33+08:00","dateModified": "2020-07-23T17:07:33+08:00","publisher": {
            "@type": "Organization",
            "name": "xls"},"author": {
                "@type": "Person",
                "name": "xls"
            },"description": ""
    }
    </script></head>
    <body header-desktop="" header-mobile=""><script type="text/javascript">(window.localStorage && localStorage.getItem('theme') ? localStorage.getItem('theme') === 'dark' : ('' === 'auto' ? window.matchMedia('(prefers-color-scheme: dark)').matches : '' === 'dark')) && document.body.setAttribute('theme', 'dark');</script>

        <div id="mask"></div><div class="wrapper"><header class="desktop" id="header-desktop">
    <div class="header-wrapper">
        <div class="header-title">
            <a href="/" title="我的Hugo博客">我的Hugo博客</a>
        </div>
        <div class="menu">
            <div class="menu-inner"><a class="menu-item" href="/posts/"> 文章 </a><a class="menu-item" href="/tags/"> 标签 </a><a class="menu-item" href="/categories/"> 分类 </a><span class="menu-item delimiter"></span><span class="menu-item search" id="search-desktop">
                        <input type="text" placeholder="搜索文章标题或内容..." id="search-input-desktop">
                        <a href="javascript:void(0);" class="search-button search-toggle" id="search-toggle-desktop" title="搜索">
                            <i class="fas fa-search fa-fw"></i>
                        </a>
                        <a href="javascript:void(0);" class="search-button search-clear" id="search-clear-desktop" title="清空">
                            <i class="fas fa-times-circle fa-fw"></i>
                        </a>
                        <span class="search-button search-loading" id="search-loading-desktop">
                            <i class="fas fa-spinner fa-fw fa-spin"></i>
                        </span>
                    </span><a href="javascript:void(0);" class="menu-item theme-switch" title="切换主题">
                    <i class="fas fa-adjust fa-fw"></i>
                </a>
            </div>
        </div>
    </div>
</header><header class="mobile" id="header-mobile">
    <div class="header-container">
        <div class="header-wrapper">
            <div class="header-title">
                <a href="/" title="我的Hugo博客">我的Hugo博客</a>
            </div>
            <div class="menu-toggle" id="menu-toggle-mobile">
                <span></span><span></span><span></span>
            </div>
        </div>
        <div class="menu" id="menu-mobile"><div class="search-wrapper">
                    <div class="search mobile" id="search-mobile">
                        <input type="text" placeholder="搜索文章标题或内容..." id="search-input-mobile">
                        <a href="javascript:void(0);" class="search-button search-toggle" id="search-toggle-mobile" title="搜索">
                            <i class="fas fa-search fa-fw"></i>
                        </a>
                        <a href="javascript:void(0);" class="search-button search-clear" id="search-clear-mobile" title="清空">
                            <i class="fas fa-times-circle fa-fw"></i>
                        </a>
                        <span class="search-button search-loading" id="search-loading-mobile">
                            <i class="fas fa-spinner fa-fw fa-spin"></i>
                        </span>
                    </div>
                    <a href="javascript:void(0);" class="search-cancel" id="search-cancel-mobile">
                        取消
                    </a>
                </div><a class="menu-item" href="/posts/" title="">文章</a><a class="menu-item" href="/tags/" title="">标签</a><a class="menu-item" href="/categories/" title="">分类</a><a href="javascript:void(0);" class="menu-item theme-switch" title="切换主题">
                <i class="fas fa-adjust fa-fw"></i>
            </a></div>
    </div>
</header>
<div class="search-dropdown desktop">
    <div id="search-dropdown-desktop"></div>
</div>
<div class="search-dropdown mobile">
    <div id="search-dropdown-mobile"></div>
</div>
<main class="main">
                <div class="container"><div class="toc" id="toc-auto">
            <h2 class="toc-title">目录</h2>
            <div class="toc-content" id="toc-content-auto"></div>
        </div><article class="page single"><h1 class="single-title animated flipInX">MySQL</h1><div class="post-meta">
            <div class="post-meta-line"><span class="post-author"><a href="/" title="Author" rel=" author" class="author"><i class="fas fa-user-circle fa-fw"></i>xls</a></span></div>
            <div class="post-meta-line"><i class="far fa-calendar-alt fa-fw"></i>&nbsp;<time datetime="2020-07-23">2020-07-23</time>&nbsp;<i class="fas fa-pencil-alt fa-fw"></i>&nbsp;约 70 字&nbsp;
                <i class="far fa-clock fa-fw"></i>&nbsp;预计阅读 1 分钟&nbsp;</div>
        </div><div class="details toc" id="toc-static"  kept="">
                <div class="details-summary toc-title">
                    <span>目录</span>
                    <span><i class="details-icon fas fa-angle-right"></i></span>
                </div>
                <div class="details-content toc-content" id="toc-content-static"><nav id="TableOfContents"></nav></div>
            </div><div class="content" id="content"><p>参考博客作者AmourLee</p>
<p><a href="https://www.cnblogs.com/dongl961230/p/13260873.html">https://www.cnblogs.com/dongl961230/p/13260873.html</a></p>
<h1 id="1mysql下载">1.MySQL下载</h1>
<p><a href="https://dev.mysql.com/downloads/mysql/">https://dev.mysql.com/downloads/mysql/</a></p>
<p><img
        class="lazyload"
        src="/svg/loading.min.svg"
        data-src="../../img/MySQL/1.png"
        data-srcset="../../img/MySQL/1.png, ../../img/MySQL/1.png 1.5x, ../../img/MySQL/1.png 2x"
        data-sizes="auto"
        alt="../../img/MySQL/1.png"
        title="../../img/MySQL/1.png" /></p>
<h1 id="2解压">2.解压</h1>
<p>下载完成后解压到自己的想要安装的目录下，然后需要手动创建一个 my.ini 文件：这个文件用来配置安装MySQL时的配置：例如端口号、最大连接数、字符集 、数据的存放位置、存储引擎</p>
<p><img
        class="lazyload"
        src="/svg/loading.min.svg"
        data-src="../../img/MySQL/2.png"
        data-srcset="../../img/MySQL/2.png, ../../img/MySQL/2.png 1.5x, ../../img/MySQL/2.png 2x"
        data-sizes="auto"
        alt="../../img/MySQL/2.png"
        title="../../img/MySQL/2.png" /></p>
<h1 id="3配置myini文件">3配置my.ini文件</h1>
<p>将下面的配置复制到自己创建的my.ini文件中，但是要注意修改自己的安装路径：basedir和datadir 有注释按照注释修改</p>
<div class="highlight"><pre class="chroma"><code class="language-ini" data-lang="ini"><span class="k">[mysqld]</span>
<span class="c1"># 设置3306端口</span>
<span class="na">port</span><span class="o">=</span><span class="s">3306</span>

<span class="c1"># 自定义设置mysql的安装目录，即解压mysql压缩包的目录</span>
<span class="na">basedir</span><span class="o">=</span><span class="s">E:\\tools\mysql8.0\mysql-8.0.20-winx64</span>

<span class="c1"># 自定义设置mysql数据库的数据存放目录</span>
<span class="na">datadir</span><span class="o">=</span><span class="s">E:\\tools\mysql8.0\mysql-8.0.20-winx64\mysqlData</span>

<span class="c1"># 允许最大连接数</span>
<span class="na">max_connections</span><span class="o">=</span><span class="s">200</span>

<span class="c1"># 允许连接失败的次数，这是为了防止有人从该主机试图攻击数据库系统</span>
<span class="na">max_connect_errors</span><span class="o">=</span><span class="s">10</span>

<span class="c1"># 服务端使用的字符集默认为UTF8</span>
<span class="na">character-set-server</span><span class="o">=</span><span class="s">utf8mb4</span>

<span class="c1"># 创建新表时将使用的默认存储引擎</span>
<span class="na">default-storage-engine</span><span class="o">=</span><span class="s">INNODB</span>

<span class="c1"># 默认使用“mysql_native_password”插件认证</span>
<span class="na">default_authentication_plugin</span><span class="o">=</span><span class="s">mysql_native_password</span>

<span class="k">[mysql]</span>
<span class="c1"># 设置mysql客户端默认字符集</span>
<span class="na">default-character-set</span><span class="o">=</span><span class="s">utf8mb4</span>

<span class="k">[client]</span>
<span class="c1"># 设置mysql客户端连接服务端时默认使用的端口和默认字符集</span>
<span class="na">port</span><span class="o">=</span><span class="s">3306</span>
<span class="na">default-character-set</span><span class="o">=</span><span class="s">utf8mb4</span>
</code></pre></div><h1 id="4初始化">4.初始化</h1>
<ul>
<li>mysqld &ndash;initialize &ndash;console</li>
<li>mysqld &ndash;install</li>
<li>net start mysql</li>
</ul>
<p><img
        class="lazyload"
        src="/svg/loading.min.svg"
        data-src="../../img/MySQL/3.png"
        data-srcset="../../img/MySQL/3.png, ../../img/MySQL/3.png 1.5x, ../../img/MySQL/3.png 2x"
        data-sizes="auto"
        alt="../../img/MySQL/3.png"
        title="../../img/MySQL/3.png" /></p>
<h1 id="5修改密码">5.修改密码</h1>
<p>win+R开启新的界面进入MySQL的bin目录然后依次执行命令，来修改客户端连接密码；</p>
<ul>
<li>mysql -u root -p</li>
<li>alter user root@localhost identified by &lsquo;root&rsquo;;</li>
</ul>
<p><img
        class="lazyload"
        src="/svg/loading.min.svg"
        data-src="../../img/MySQL/4.png"
        data-srcset="../../img/MySQL/4.png, ../../img/MySQL/4.png 1.5x, ../../img/MySQL/4.png 2x"
        data-sizes="auto"
        alt="../../img/MySQL/4.png"
        title="../../img/MySQL/4.png" /></p>
<p>回车界面出现：Query OK 证明修改成功。</p>
<p><img
        class="lazyload"
        src="/svg/loading.min.svg"
        data-src="../../img/MySQL/5.jpg"
        data-srcset="../../img/MySQL/5.jpg, ../../img/MySQL/5.jpg 1.5x, ../../img/MySQL/5.jpg 2x"
        data-sizes="auto"
        alt="../../img/MySQL/5.jpg"
        title="../../img/MySQL/5.jpg" /></p>
</div><div class="post-footer" id="post-footer">
    <div class="post-info">
        <div class="post-info-line">
            <div class="post-info-mod">
                <span>更新于 2020-07-23</span>
            </div>
            <div class="post-info-license"></div>
        </div>
        <div class="post-info-line">
            <div class="post-info-md"></div>
            <div class="post-info-share">
                <span><a href="javascript:void(0);" title="分享到 Twitter" data-sharer="twitter" data-url="https://xls7771.gitee.io/posts/mysql/" data-title="MySQL"><i class="fab fa-twitter fa-fw"></i></a><a href="javascript:void(0);" title="分享到 Facebook" data-sharer="facebook" data-url="https://xls7771.gitee.io/posts/mysql/"><i class="fab fa-facebook-square fa-fw"></i></a><a href="javascript:void(0);" title="分享到 Buffer" data-sharer="buffer" data-url="https://xls7771.gitee.io/posts/mysql/" data-title="MySQL"><i class="fab fa-buffer fa-fw"></i></a><a href="javascript:void(0);" title="分享到 百度" data-sharer="baidu" data-url="https://xls7771.gitee.io/posts/mysql/" data-title="MySQL"><i data-svg-src="/lib/simple-icons/icons/baidu.min.svg"></i></a></span>
            </div>
        </div>
    </div>

    <div class="post-info-more">
        <section class="post-tags"></section>
        <section>
            <span><a href="javascript:void(0);" onclick="window.history.back();">返回</a></span>&nbsp;|&nbsp;<span><a href="/">主页</a></span>
        </section>
    </div>

    <div class="post-nav"><a href="/posts/tomcat/" class="prev" rel="prev" title="Tomcat"><i class="fas fa-angle-left fa-fw"></i>Tomcat</a>
            <a href="/posts/mybatisplus/" class="next" rel="next" title="MyBatisPlus">MyBatisPlus<i class="fas fa-angle-right fa-fw"></i></a></div>
</div>
</article></div>
            </main><footer class="footer">
        <div class="footer-container"><div class="footer-line">由 <a href="https://gohugo.io/" target="_blank" rel="noopener noreffer" title="Hugo 0.74.2">Hugo</a> 强力驱动 | 主题 - <a href="https://github.com/dillonzq/LoveIt" target="_blank" rel="noopener noreffer" title="LoveIt 0.2.10"><i class="far fa-kiss-wink-heart fa-fw"></i> LoveIt</a>
                </div><div class="footer-line"><i class="far fa-copyright fa-fw"></i><span itemprop="copyrightYear">2020</span><span class="author" itemprop="copyrightHolder">&nbsp;<a href="/" target="_blank">xls</a></span></div>
        </div>
    </footer></div>

        <div id="fixed-buttons"><a href="#" id="back-to-top" class="fixed-button" title="回到顶部">
                <i class="fas fa-arrow-up fa-fw"></i>
            </a><a href="#" id="view-comments" class="fixed-button" title="查看评论">
                <i class="fas fa-comment fa-fw"></i>
            </a>
        </div><script type="text/javascript" src="/lib/smooth-scroll/smooth-scroll.min.js"></script><script type="text/javascript" src="/lib/autocomplete/autocomplete.min.js"></script><script type="text/javascript" src="/lib/lunr/lunr.min.js"></script><script type="text/javascript" src="/lib/lunr/lunr.stemmer.support.min.js"></script><script type="text/javascript" src="/lib/lunr/lunr.zh.min.js"></script><script type="text/javascript" src="/lib/lazysizes/lazysizes.min.js"></script><script type="text/javascript" src="/lib/clipboard/clipboard.min.js"></script><script type="text/javascript" src="/lib/sharer/sharer.min.js"></script><script type="text/javascript">window.config={"code":{"copyTitle":"复制到剪贴板","maxShownLines":10},"comment":{},"search":{"highlightTag":"em","lunrLanguageCode":"zh","lunrSegmentitURL":"/lib/lunr/lunr.segmentit.js","maxResultLength":10,"noResultsFound":"没有找到结果","snippetLength":30}};</script><script type="text/javascript" src="/js/theme.min.js"></script></body>
</html>
